home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / GAMES / P_ROBO31 / M66.PR < prev    next >
Text File  |  1993-02-26  |  3KB  |  86 lines

  1. (**************************************************************************)
  2. (*                             W A R N I N G                              *)
  3. (*                                                                        *)
  4. (*  This Robot has NOT been designed to take advantage of the advanced    *)
  5. (*  features of P-ROBOTS, such as, Shields, Fuel, Teams or Obstructions.  *)
  6. (**************************************************************************)
  7.  
  8.   PROCEDURE M66;
  9.     { Based on C-Robot M66 : programmed by OBI-ONE }
  10.  
  11.   VAR
  12.     drv_dir        : Integer; { drive direction }
  13.     scn_dir        : Integer; { scan direction }
  14.     step           : Integer; { scan step }
  15.     degs           : Integer; { half of scan step }
  16.     Range          : ARRAY[-2..2] OF Integer; { range to oponent }
  17.     range_sv       : Integer; { range of last scan }
  18.     found          : Boolean; { foe found ? }
  19.     x, y           : Integer;
  20.  
  21.  
  22.     PROCEDURE Move;
  23.     BEGIN
  24.       x := loc_x;
  25.       y := loc_y;
  26.       IF (x < 200)
  27.       THEN drv_dir := Random(45)
  28.       ELSE IF (x > 800) THEN drv_dir := Random(45)+180;
  29.  
  30.       IF (y < 200)
  31.       THEN drv_dir := Random(45)+90
  32.       ELSE IF (y > 800) THEN drv_dir := Random(45)+270;
  33.  
  34.       drive(drv_dir, 100);
  35.     END; {Move}
  36.  
  37.     PROCEDURE attack;
  38.     VAR I, Pick    : Integer;
  39.     BEGIN
  40.       IF ObjectScanned = Enemy
  41.         THEN cannon(scn_dir, range_sv);{shoot at last foe postion}
  42.       Pick := 99;
  43.       FOR I := -2 TO 2 DO
  44.         BEGIN
  45.           Range[I] := scan(scn_dir+step*I, degs);
  46.           IF Range[I] > 40 THEN
  47.             BEGIN
  48.               Pick := I;
  49.               I := 2;
  50.             END;
  51.         END;
  52.       IF Pick <> 99 THEN
  53.         BEGIN
  54.           found := True;
  55.           range_sv := Range[Pick];
  56.           scn_dir := scn_dir+step*Pick;
  57.           IF ObjectScanned = Enemy
  58.             THEN cannon(scn_dir, range_sv);
  59.         END
  60.       ELSE scn_dir := scn_dir+120;
  61.     END; {Attack}
  62.  
  63.   BEGIN {M66 Main}
  64.     drv_dir := Random(360); { initialize }
  65.     scn_dir := drv_dir+120;
  66.     found := False;
  67.     range_sv := 700;
  68.     step := 20;
  69.     degs := step DIV 2;
  70.  
  71.     REPEAT { main loop }
  72.  
  73.       { drive at full speed.                       }
  74.       { when close to wall, turn around at random. }
  75.  
  76.       Move;
  77.  
  78.       { scan every 20 degrees resolution. }
  79.       { if you find a foe, then attack it with your cannon. }
  80.  
  81.       attack;
  82.  
  83.     UNTIL Dead OR Winner; { end of main loop }
  84.  
  85.   END; {M66 Main}
  86.